#include<iostream>
using namespace std;



void print(int *arr,int n);


void swap(int *left, int *right)
{
    int temp = *left;
    *left = *right;
    *right = temp;
}

int _Quick(int *arr,int l,int r)
{
    int cur = l+1;
    int pre=l;
    int base = arr[l];
    while(cur<r)
    {
        if(arr[cur] < base)
        {
            pre++;
            swap(arr[cur],arr[pre]);
        }
        cur++;
    }
    swap(arr[l],arr[pre]);
    return pre;

}
int QuickSort(int *arr ,int l ,int r)
{
    if(l>=r)
       return 0;
    int mid= _Quick(arr,l,r);
    QuickSort(arr,l,mid);
    QuickSort(arr,mid+1,r);
    return 0;
}








void print(int *arr,int n)
{
    for(int i=0;i<n;i++)
        cout<< arr[i]<<' ' ;
    cout<< endl;

 }

int main()
{
    int a[11] ={2, 8, 4, 5, 9, 4, 42, 0, 3, 6, 8};
    int n=11;
    QuickSort(a,0,n);
    print(a,n);
    return 0;
}


